package com.tarena.luban.worker.server.repo;

import com.tarena.luban.worker.server.bo.WorkerCategoryBO;
import com.tarena.luban.worker.server.dao.WorkerCategoryDao;
import com.tarena.luban.worker.server.repo.converter.WorkerCategoryConverter;
import com.tarena.luban.worker.server.repository.WorkerCategoryRepsoitory;
import com.tarena.tp.luban.worker.po.WorkerCategory;
import com.tarena.tp.luban.worker.server.dto.param.WorkerCategoryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author java@tedu.cn
 * @version 1.0
 */
@Repository
public class WorkerCategoryRepoImpl implements WorkerCategoryRepsoitory {
    @Autowired
    private WorkerCategoryDao workerCategoryDao;
    @Autowired
    private WorkerCategoryConverter workerCategoryConverter;
    @Override
    public void deleteByUserId(Long userId) {
        workerCategoryDao.deleteByUserId(userId);
    }

    @Override
    public void save(WorkerCategoryParam param) {
        //转化
        WorkerCategory workerCategory = workerCategoryConverter.param2po(param);
        workerCategoryDao.insert(workerCategory);
    }

    @Override
    public List<WorkerCategoryBO> selectByUserId(Long userId) {
        //读po
        List<WorkerCategory> workerCategories=workerCategoryDao.selectCategoryByUserId(userId);
        //转化bo
        return workerCategoryConverter.poList2BoList(workerCategories);
    }
}
